<include file="Public/header"/>
<div class="row">
  <div class="col-md-12">
    <div class="ibox float-e-margins">
      <!--条件查询-->
      <div class="ibox-title">
        <a href="javascript:void(0)" onclick="history.go(-1)" class="pull-left" style="margin-right: 10px;"><i class="layui-icon"></i></a>
        <h5>交易统计</h5>
        <div class="ibox-tools">
          <i class="layui-icon" onclick="location.replace(location.href);" title="刷新"
             style="cursor:pointer;">ဂ</i>
        </div>
      </div>
      <!--条件查询-->
      <div class="ibox-content">
        <form class="layui-form" action="" method="get" autocomplete="off" id="orderform">
          <!--<input type="hidden" name="m" value="<{$model}>">-->
          <!--<input type="hidden" name="c" value="Order">-->
          <!--<input type="hidden" name="a" value="index" id="action">-->
          <!--<div class="layui-form-item">-->
            <!--<div class="layui-inline">-->
              <!--<div class="layui-input-inline">-->
                <!--<input type="text" name="memberid" autocomplete="off" placeholder="请输入商户号"-->
                       <!--class="layui-input" value="<{$_GET['memberid']}>">-->
              <!--</div>-->
              <!--<div class="layui-input-inline">-->
                <!--<input type="text" name="orderid" autocomplete="off" placeholder="商户订单号"-->
                       <!--class="layui-input" value="<{$_GET['orderid']}>">-->
              <!--</div>-->
              <!--<div class="layui-input-inline">-->
                <!--<input type="text" name="pay_orderid" autocomplete="off" placeholder="平台订单号"-->
                       <!--class="layui-input" value="<{$_GET['pay_orderid']}>">-->
              <!--</div>-->
            <!--</div>-->
            <div class="layui-input-inline">
              <select name="tongdao">
                <option <if condition="$_GET[tongdao] eq 297">selected</if> value="297">当面付（睿耀）</option>
                <option <if condition="$_GET[tongdao] eq 299">selected</if> value="299">当面付（百讯）</option>
                <option <if condition="$_GET[tongdao] eq 300">selected</if> value="300">当面付（国莱）	</option>
                <option <if condition="$_GET[tongdao] eq 301">selected</if> value="301">当面付（武能）</option>
				<option <if condition="$_GET[tongdao] eq 303">selected</if> value="303">当面付（雨合）</option>
              </select>
            </div>
            <div class="layui-inline">
              <div class="layui-input-inline">
                <input style="width:400px;" type="text" class="layui-input" name="pay_applydate" id="createtime"
                       placeholder="提交时间段" value="<{$_GET['pay_applydate']}>">
              </div>
              <!--<div class="layui-input-inline">-->
                <!--<input type="text" class="layui-input" name="successtime" id="successtime"-->
                       <!--placeholder="成功时间段" value="<{$_GET['successtime']}>">-->
              <!--</div>-->
            </div>
            <!--<div class="layui-inline">-->

              <!--<div class="layui-input-inline">-->
                <!--<select name="bank">-->
                  <!--<option value="">全部银行</option>-->
                  <!--<volist name="banklist" id="vo">-->
                    <!--<option <if condition="$_GET[bank] eq $vo[id]">selected</if>-->
                    <!--value="<{$vo.id}>"><{$vo.name}></option>-->
                  <!--</volist>-->
                <!--</select>-->
              <!--</div>-->
              <!--<div class="layui-input-inline">-->
                <!--<select name="status">-->
                  <!--<option value="">全部状态</option>-->
                  <!--<option <if condition="$_GET[status] neq '' && $_GET[status] eq 0">selected</if> value="0">未处理</option>-->
                  <!--<option <if condition="$_GET[status] eq 1">selected</if> value="1">成功，未返回</option>-->
                  <!--<option <if condition="$_GET[status] eq 2">selected</if> value="2">成功，已返回</option>-->
                  <!--<option <if condition="$_GET[status] eq '1or2'">selected</if> value="1or2">成功，已/未返回</option>-->
                <!--</select>-->
              <!--</div>-->
              <!--<div class="layui-input-inline">-->
                <!--<select name="ddlx">-->
                  <!--<option value="">订单类型</option>-->
                  <!--<option <if condition="$_GET[ddlx] neq '' && $_GET[ddlx] eq 0">selected</if> value="0">收款订单</option>-->
                  <!--<option <if condition="$_GET[ddlx] eq 1">selected</if> value="1">充值订单</option>-->
                <!--</select>-->
              <!--</div>-->
            <!--</div>-->

            <div class="layui-inline">
              <button type="submit" class="layui-btn"><span
                      class="glyphicon glyphicon-search"></span> 搜索
              </button>
              <!--<a href="javascript:;" id="export" class="layui-btn layui-btn-warm"><span class="glyphicon glyphicon-export"></span> 导出数据</a>-->
              <!--<eq name="isrootadmin"  value="true">-->
                <!--<a href="javascript:;" id="delorder" onclick="chooseOrder_del()" class="layui-btn layui-btn-danger"><span class="glyphicon glyphicon-trash"></span>选择删除无效订单</a>-->
              <!--</eq>-->
            </div>
          </form>
        </div>
        <!-- <div class="ibox float-e-margins chart item">
        <div class="ibox-title"><h5>交易统计</h5></div>
          <div class="ibox-content no-padding">
            <div class="panel-body">
              <div class="panel-group" id="version">
                <div class="col-lg-12"><div id="dmonth" style="height:280px;"></div></div>
              </div>
            </div>
          </div>
        </div> -->
        <div class="list item">
          <!--交易列表-->
          <table class="layui-table" lay-data="{width:'100%',limit:<{$rows}>,id:'userData'}">
            <thead>
            <tr>
              <th lay-data="{field:'ddlx', width:230}">收款账号</th>
                <th lay-data="{field:'memberid', width:160}">成功笔数</th>
                <th lay-data="{field:'out_trade_id', width:160,style:'color:#060;'}">请求笔数</th>
                <th lay-data="{field:'pay_orderid', width:160,style:'color:#060;'}">成功率</th>
                <th lay-data="{field:'amount', width:160,style:'color:#060;'}">交易金额</th>
                <th lay-data="{field:'rate', width:160}">日交易额</th>
                <th lay-data="{field:'actualamount', width:160,style:'color:#C00;'}">总交易额</th>
                <th lay-data="{field:'pay_status',width:120}">账户状态</th>
            </tr>
            </thead>
            <tbody>
              <volist name="stat" id="vo">
                <tr>
                  <td><{$vo['title']}></td>
                  <td style="text-align:center;"><{$vo['success']}></td>
                  <td style="text-align:center; color:#090;"><{$vo['request']}></td>
                  <?php
                    if($vo['success']){
                      $chance = $vo['success']/$vo['request'];
                      $chance = round($chance*100,2);
                      $chance = $chance.'%';
                    }else{
                      $chance = 0;
                    }
                  ?>
                  <td style="text-align:center; color:#060"><{$chance}></td>
                  <td style="text-align:center; color:#090;"><{$vo['amount']}></td>
                  <td style="text-align:center; color:#090;"><{$vo['todayamount']}></td>
                  <td style="text-align:center; color:#090;"><{$vo['allamount']}></td>
                  <td style="text-align:center; color:#666">
                    <if condition="$vo['status'] == 1">
                      <span style="color:red">开启</span>
                    <else />
                      关闭
                    </if>
                  </td>
                  <!--<td style="text-align:center; color:#C00"><{$vo['2']['profit']}></td>-->

                </tr>
              </volist>
            </tbody>
          </table>
          <!--交易列表-->
          <div class="page">

          </div>
        </div>
      </div>
    </div>

  </div>
  <include file="Public/footer"/>
  <script src="/Public/Front/js/echarts.common.min.js"></script>
  <script>
      $('#pageList').change(function(){
          $('#pageForm').submit();
      });
      layui.use(['laydate', 'laypage', 'layer', 'table', 'form'], function() {
          var laydate = layui.laydate //日期
              , laypage = layui.laypage //分页
              ,layer = layui.layer //弹层
              ,form = layui.form //表单
              , table = layui.table; //表格
          //日期时间范围
          laydate.render({
              elem: '#createtime'
              , type: 'datetime'
              ,theme: 'molv'
              , range: '|'
          });
          //日期时间范围
          laydate.render({
              elem: '#successtime'
              , type: 'datetime'
              ,theme: 'molv'
              , range: '|'
          });
      });
      /*订单-查看*/
      function order_view(title,url,w,h){
          x_admin_show(title,url,w,h);
      }
      $('#export').on('click',function(){
          var time = "<{$applyTTime}>"; //导出订单的时间段不能大于一个星期
          if (time <= 0){
              layer.alert('请选择"提交时间段"，点击搜索，再导出，只能导出一个星期内的订单');
              return;
          }
          if(time > 7*24*60*60) {
              layer.alert('请选择"提交时间段"，点击搜索，再导出，只能导出一个星期内的订单');
              return;
          }
          window.location.href
              = "<{:U('Admin/Order/orderStat').'?memberid='.$_GET[memberid].'&orderid='.$_GET[orderid].'&createtime='.$_GET[createtime].'&successtime='.$_GET[successtime].'&tongdao='.$_GET[tongdao].'&bank='.$_GET[bank].'&status='.$_GET[status].'&ddlx='.$_GET[ddlx]}>";
      });

      function chooseOrder_del() {
          var createtime=$("#createtime").val();
          if(createtime==""){
              layer.alert('请选择删除无效订单创建时间段');
              return;
          }
          layer.confirm('删除操作为真实删除，确定要删除时间段从'+createtime.replace('|','到')+'的无效订单吗？',function(index){
              $.ajax({
                  url:"<{:U('Order/delOrder')}>",
                  type:'post',
                  data:{'createtime':createtime},
                  success:function(res){
                      if(res.status){
                          layer.alert(res.msg,function () {
                              location.replace(location.href);
                          });
                      }else{
                          layer.alert(res.msg);
                      }
                  }
              });
          });
      }

      var myChart = echarts.init(document.getElementById('dmonth'));
      myChart.setOption({
          tooltip : {
              trigger: 'axis',
              axisPointer: {
                  type: 'cross',
                  label: {
                      backgroundColor: '#6a7985'
                  }
              }
          },
          legend: {
              data:['交易金额','收入金额','支出金额']
          },
          toolbox: {
              feature: {
                  saveAsImage: {}
              }
          },
          grid: {
              left: '3%',
              right: '4%',
              bottom: '3%',
              containLabel: true
          },
          xAxis : [
              {
                  type : 'category',
                  boundaryGap : false,
                  data : [<{$mdata.mdate|implode=","}>]
      }
      ],
      yAxis : [
          {
              type : 'value'
          }
      ],
          series : [
          {
              name:'交易金额',
              type:'line',
              stack: '总量',
              areaStyle: {normal: {}},
              data:[<{$mdata.amount|implode=","}>]
      },
      {
          name:'收入金额',
              type:'line',
          stack: '总量',
          areaStyle: {normal: {}},
          data:[<{$mdata.rate|implode=","}>]
      },
      {
          name:'支出金额',
              type:'line',
          stack: '总量',
          areaStyle: {normal: {}},
          data:[<{$mdata.total|implode=","}>]
      },
      ]
      });

  </script>
  </body>
  </html>